package com.esri.android.map.popup;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.text.util.Linkify;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import androidx.core.internal.view.SupportMenu;
import androidx.core.view.InputDeviceCompat;
import com.esri.android.map.ags.ArcGISPopupInfo;
import com.esri.android.map.popup.ArcGISAttributesAdapter;
import com.esri.android.map.popup.ArcGISPopupStyle;
import com.esri.core.internal.util.g;
import com.esri.core.map.CodedValueDomain;
import com.esri.core.map.Domain;
import com.esri.core.map.Field;
import com.esri.core.map.RangeDomain;
import java.util.Calendar;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import kotlin.jvm.internal.LongCompanionObject;
import kotlin.jvm.internal.ShortCompanionObject;

/* loaded from: classes.dex */
public class ArcGISEditAttributesAdapter extends ArcGISAttributesAdapter implements PopupValid {
    protected static final String NULL = "<No value>";
    AtomicInteger a;
    public int mDateTimeViewId;

    /* loaded from: classes.dex */
    public interface Required {
        boolean getRequiredState();

        void setRequiredState(boolean z);
    }

    public ArcGISEditAttributesAdapter(Context context, Popup popup) {
        super(context, popup);
        this.a = new AtomicInteger(0);
    }

    public Map<String, Object> getAttributes() {
        return new LinkedHashMap(this.mAttributes);
    }

    @Override // com.esri.android.map.popup.ArcGISAttributesAdapter
    protected ViewGroup createDefaultLayout(ArcGISAttributesAdapter.FIELD_TYPE field_type) {
        View separatorView;
        View bVar;
        LinearLayout linearLayout = new LinearLayout(this.mContext);
        linearLayout.setOrientation(1);
        ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) this.mPopup.getLayout().getStyle();
        ArcGISAttributesAdapter.FieldLabelView fieldLabelView = new ArcGISAttributesAdapter.FieldLabelView(this.mContext, "", arcGISPopupStyle);
        fieldLabelView.setId(1);
        linearLayout.addView(fieldLabelView);
        if (arcGISPopupStyle.getCustomFieldSeparator() != null) {
            separatorView = arcGISPopupStyle.getCustomFieldSeparator();
        } else {
            separatorView = new ArcGISAttributesAdapter.SeparatorView(this.mContext, arcGISPopupStyle);
        }
        linearLayout.addView(separatorView);
        int i = AnonymousClass3.a[field_type.ordinal()];
        if (i == 1 || i == 2) {
            bVar = new b(this.mContext);
        } else if (i == 3) {
            bVar = new c(this.mContext);
        } else {
            bVar = new DefaultAttributeValueEditText(this.mContext);
        }
        bVar.setId(2);
        linearLayout.addView(bVar);
        return linearLayout;
    }

    @Override // android.widget.Adapter
    public View getView(int i, View view, ViewGroup viewGroup) {
        ArcGISPopupInfo arcGISPopupInfo;
        ArcGISAttributesAdapter.AttributeInfo attributeInfo = getAttributeInfo(i);
        if ((attributeInfo.field == null || attributeInfo.field.isEditable()) && (attributeInfo.fieldInfo == null || (attributeInfo.fieldInfo.isVisible() && attributeInfo.fieldInfo.isEditable()))) {
            if (!(this.mPopup.a instanceof ArcGISPopupInfo)) {
                arcGISPopupInfo = new ArcGISPopupInfo(this.mPopup.a);
            } else {
                arcGISPopupInfo = (ArcGISPopupInfo) this.mPopup.a;
            }
            ArcGISAttributesAdapter.FIELD_TYPE determineFieldType = determineFieldType(attributeInfo);
            if (determineFieldType == ArcGISAttributesAdapter.FIELD_TYPE.UNSUPPORTED) {
                return null;
            }
            ArcGISAttributesAdapter.LayoutResource layoutResource = getLayoutResource(determineFieldType);
            ViewGroup createLayout = layoutResource.createLayout();
            TextView textView = (TextView) createLayout.findViewById(layoutResource.mLabelViewId);
            if (attributeInfo.field == null && attributeInfo.fieldInfo == null) {
                textView.setText("");
            } else {
                textView.setText(attributeInfo.fieldInfo == null ? attributeInfo.field.getName() : attributeInfo.fieldInfo.getLabel().toUpperCase(Locale.getDefault()));
            }
            int i2 = AnonymousClass3.a[determineFieldType.ordinal()];
            if (i2 == 1) {
                Spinner spinner = (Spinner) createLayout.findViewById(layoutResource.mValueViewId);
                if (attributeInfo.field != null) {
                    spinner.setTag(attributeInfo.field.isNullable() ? Boolean.FALSE : Boolean.TRUE);
                    a(spinner, attributeInfo.field.getName());
                }
                Map<String, String> codedValues = ((CodedValueDomain) attributeInfo.domain).getCodedValues();
                if (attributeInfo.field != null && !attributeInfo.field.getName().equals(arcGISPopupInfo.getTypeIdField()) && attributeInfo.field.isNullable()) {
                    codedValues.put(null, NULL);
                }
                CodedValueSpinnerAdapter codedValueSpinnerAdapter = new CodedValueSpinnerAdapter(codedValues);
                spinner.setAdapter((SpinnerAdapter) codedValueSpinnerAdapter);
                spinner.setSelection(codedValueSpinnerAdapter.getPosition(attributeInfo));
                if ((attributeInfo.value == null || String.valueOf(attributeInfo.value).length() == 0) && attributeInfo.field != null) {
                    setRequiredState(spinner, !attributeInfo.field.isNullable());
                }
            } else if (i2 == 2) {
                Spinner spinner2 = (Spinner) createLayout.findViewById(layoutResource.mValueViewId);
                if (attributeInfo.field != null) {
                    spinner2.setTag(attributeInfo.field.isNullable() ? Boolean.FALSE : Boolean.TRUE);
                    a(spinner2, attributeInfo.field.getName());
                }
                double minValue = attributeInfo.domain == null ? Double.MIN_VALUE : ((RangeDomain) attributeInfo.domain).getMinValue();
                spinner2.setAdapter(new RangeSpinnerAdapter(minValue, attributeInfo.domain == null ? Double.MAX_VALUE : ((RangeDomain) attributeInfo.domain).getMaxValue()));
                if (attributeInfo.value != null) {
                    spinner2.setSelection((int) (Double.parseDouble(attributeInfo.value.toString()) - minValue));
                } else if (attributeInfo.field != null) {
                    setRequiredState(spinner2, !attributeInfo.field.isNullable());
                }
            } else if (i2 == 3) {
                Button button = (Button) createLayout.findViewById(layoutResource.mValueViewId);
                if (attributeInfo.field != null) {
                    button.setTag(attributeInfo.field.isNullable() ? Boolean.FALSE : Boolean.TRUE);
                }
                long j = Long.MIN_VALUE;
                long j2 = LongCompanionObject.MAX_VALUE;
                if (attributeInfo.domain != null && (attributeInfo.domain instanceof RangeDomain)) {
                    j = (long) ((RangeDomain) attributeInfo.domain).getMinValue();
                    j2 = (long) ((RangeDomain) attributeInfo.domain).getMaxValue();
                }
                long j3 = j2;
                long j4 = j;
                System.currentTimeMillis();
                if (attributeInfo.value != null) {
                    try {
                        long parseLong = Long.parseLong(attributeInfo.value.toString());
                        if (attributeInfo.field != null) {
                            button.setText(this.mValueFormat.formatValue(this.mFeatureType, Long.valueOf(parseLong), this.mPopup.a.getFieldInfo(attributeInfo.field.getName())));
                        }
                    } catch (NumberFormatException unused) {
                    }
                } else if (attributeInfo.field != null) {
                    setRequiredState(button, !attributeInfo.field.isNullable());
                }
                button.setOnClickListener(new DateButtonOnClickListener(attributeInfo, j4, j3));
            } else {
                EditText editText = (EditText) createLayout.findViewById(layoutResource.mValueViewId);
                if (attributeInfo.field != null) {
                    editText.setTag(attributeInfo.field.isNullable() ? Boolean.FALSE : Boolean.TRUE);
                }
                a(editText, attributeInfo.field == null ? "" : attributeInfo.field.getName(), attributeInfo.field == null ? -1 : attributeInfo.field.getLength(), attributeInfo.field == null ? 60 : attributeInfo.field.getFieldType(), attributeInfo.domain);
                String valueOf = attributeInfo.value != null ? String.valueOf(attributeInfo.value) : null;
                editText.setText(valueOf);
                if (attributeInfo.fieldInfo != null) {
                    editText.setHint((attributeInfo.fieldInfo.getTooltip() == null || attributeInfo.fieldInfo.getTooltip().equals("")) ? attributeInfo.fieldInfo.getLabel() : attributeInfo.fieldInfo.getTooltip());
                }
                if ((valueOf == null || valueOf.length() == 0) && attributeInfo.field != null) {
                    setRequiredState(editText, !attributeInfo.field.isNullable());
                }
            }
            return createLayout;
        }
        return null;
    }

    protected void setRequiredState(View view, boolean z) {
        if ((view instanceof Required) && Boolean.TRUE.equals(view.getTag())) {
            Required required = (Required) view;
            if (required.getRequiredState() != z) {
                required.setRequiredState(z);
            }
        }
    }

    private void a(Spinner spinner, String str) {
        ArcGISPopupInfo arcGISPopupInfo;
        if (!(this.mPopup.a instanceof ArcGISPopupInfo)) {
            arcGISPopupInfo = new ArcGISPopupInfo(this.mPopup.a);
        } else {
            arcGISPopupInfo = (ArcGISPopupInfo) this.mPopup.a;
        }
        Field field = arcGISPopupInfo == null ? null : arcGISPopupInfo.getField(str);
        spinner.setPrompt(field != null ? field.getAlias() : str);
        spinner.setOnItemSelectedListener(new AnonymousClass1(spinner, arcGISPopupInfo, str));
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.esri.android.map.popup.ArcGISEditAttributesAdapter$1  reason: invalid class name */
    /* loaded from: classes.dex */
    public class AnonymousClass1 implements AdapterView.OnItemSelectedListener {
        int a;
        final /* synthetic */ Spinner b;
        final /* synthetic */ ArcGISPopupInfo c;
        final /* synthetic */ String d;
        private boolean f = true;

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onNothingSelected(AdapterView<?> adapterView) {
        }

        AnonymousClass1(Spinner spinner, ArcGISPopupInfo arcGISPopupInfo, String str) {
            this.b = spinner;
            this.c = arcGISPopupInfo;
            this.d = str;
            this.a = spinner.getSelectedItemPosition();
        }

        /* JADX WARN: Removed duplicated region for block: B:27:0x0076  */
        /* JADX WARN: Removed duplicated region for block: B:28:0x00cf  */
        @Override // android.widget.AdapterView.OnItemSelectedListener
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct code enable 'Show inconsistent code' option in preferences
        */
        public void onItemSelected(android.widget.AdapterView<?> r9, android.view.View r10, final int r11, long r12) {
            /*
                Method dump skipped, instructions count: 270
                To view this dump change 'Code comments level' option to 'DEBUG'
            */
            throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.popup.ArcGISEditAttributesAdapter.AnonymousClass1.onItemSelected(android.widget.AdapterView, android.view.View, int, long):void");
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0077, code lost:
        if (((com.esri.core.map.CodedValueDomain) r15).getCodedValues().containsValue(r12) != false) goto L21;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x0098, code lost:
        if (r16 <= r15.getMaxValue()) goto L21;
     */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00b0  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00bb A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    boolean a(com.esri.core.map.FeatureTemplate r21, com.esri.core.map.FeatureType r22, com.esri.android.map.ags.ArcGISPopupInfo r23, java.lang.Object r24, boolean r25) {
        /*
            Method dump skipped, instructions count: 272
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.popup.ArcGISEditAttributesAdapter.a(com.esri.core.map.FeatureTemplate, com.esri.core.map.FeatureType, com.esri.android.map.ags.ArcGISPopupInfo, java.lang.Object, boolean):boolean");
    }

    /* loaded from: classes.dex */
    private class b extends Spinner implements Required, ArcGISPopupStyle.IPopupStylable {
        SpinnerBackgroundDrawable a;

        public b(Context context) {
            super(context);
            setPadding(PopupUtil.convertDpInPixels(context, 1), PopupUtil.convertDpInPixels(context, 1), PopupUtil.convertDpInPixels(context, 40), PopupUtil.convertDpInPixels(context, 1));
            setMinimumHeight(ArcGISEditAttributesAdapter.this.a());
            SpinnerBackgroundDrawable spinnerBackgroundDrawable = new SpinnerBackgroundDrawable();
            this.a = spinnerBackgroundDrawable;
            setBackgroundDrawable(spinnerBackgroundDrawable);
            ((ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle()).registerStylable(this);
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public boolean getRequiredState() {
            return this.a.a;
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public void setRequiredState(boolean z) {
            this.a.a = z;
            if (z) {
                synchronized (ArcGISEditAttributesAdapter.this.a) {
                    if (ArcGISEditAttributesAdapter.this.a.incrementAndGet() == 1 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                        ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(false);
                    }
                }
                return;
            }
            synchronized (ArcGISEditAttributesAdapter.this.a) {
                if (ArcGISEditAttributesAdapter.this.a.get() > 0 && ArcGISEditAttributesAdapter.this.a.decrementAndGet() == 0 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                    ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(true);
                }
            }
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public Set<ArcGISPopupStyle.STYLE_ELEMENT> getRegisteredStyle() {
            return EnumSet.of(ArcGISPopupStyle.STYLE_ELEMENT.EDIT_FIELD);
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public void applyStyle(ArcGISPopupStyle arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT style_element) {
            SpinnerBackgroundDrawable spinnerBackgroundDrawable = new SpinnerBackgroundDrawable();
            this.a = spinnerBackgroundDrawable;
            setBackgroundDrawable(spinnerBackgroundDrawable);
        }
    }

    /* loaded from: classes.dex */
    protected class CodedValueSpinnerAdapter implements SpinnerAdapter {
        LinkedHashMap<String, String> a;
        private String[] c;

        @Override // android.widget.Adapter
        public int getItemViewType(int i) {
            return 0;
        }

        @Override // android.widget.Adapter
        public int getViewTypeCount() {
            return 1;
        }

        @Override // android.widget.Adapter
        public boolean hasStableIds() {
            return false;
        }

        @Override // android.widget.Adapter
        public void registerDataSetObserver(DataSetObserver dataSetObserver) {
        }

        @Override // android.widget.Adapter
        public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
        }

        public CodedValueSpinnerAdapter(Map<String, String> map) {
            if (map == null) {
                this.a = new LinkedHashMap<>(0);
            } else {
                setKeyValues(map);
            }
        }

        public void setKeyValues(Map<String, String> map) {
            LinkedHashMap<String, String> linkedHashMap = this.a;
            if (linkedHashMap == null) {
                this.a = new LinkedHashMap<>(map == null ? 0 : map.size());
            } else {
                linkedHashMap.clear();
            }
            if (map != null) {
                this.a.putAll(map);
            }
            this.c = (String[]) this.a.keySet().toArray(new String[0]);
        }

        public int getPosition(ArcGISAttributesAdapter.AttributeInfo attributeInfo) {
            String obj = attributeInfo.value == null ? null : attributeInfo.value.toString();
            boolean z = false;
            if (attributeInfo.field != null && attributeInfo.field.getFieldType() == 30) {
                z = true;
            }
            int i = -1;
            for (String str : this.a.keySet()) {
                i++;
                if ((str == null && obj == null) || (str != null && str.equals(obj))) {
                    return i;
                }
                if (!g.a(str) && !g.a(obj) && z && Double.valueOf(str).equals(Double.valueOf(obj))) {
                    return i;
                }
            }
            return i + 1;
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            TextViewSpinner textViewSpinner;
            if (view != null && (view instanceof TextViewSpinner)) {
                textViewSpinner = (TextViewSpinner) view;
            } else {
                ArcGISEditAttributesAdapter arcGISEditAttributesAdapter = ArcGISEditAttributesAdapter.this;
                textViewSpinner = new TextViewSpinner(arcGISEditAttributesAdapter.mContext);
                int convertDpInPixels = PopupUtil.convertDpInPixels(ArcGISEditAttributesAdapter.this.mContext, 10);
                textViewSpinner.setPadding(convertDpInPixels, convertDpInPixels, convertDpInPixels, convertDpInPixels);
            }
            if (i >= getCount()) {
                textViewSpinner.setText((CharSequence) null);
            } else {
                textViewSpinner.setText(this.a.get(getItem(i)));
            }
            return textViewSpinner;
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            if (i >= getCount()) {
                return -1L;
            }
            return i;
        }

        @Override // android.widget.Adapter
        public String getItem(int i) {
            if (i >= getCount()) {
                return null;
            }
            return this.c[i];
        }

        @Override // android.widget.Adapter
        public int getCount() {
            return this.c.length;
        }

        @Override // android.widget.Adapter
        public boolean isEmpty() {
            return getCount() == 0;
        }

        @Override // android.widget.SpinnerAdapter
        public View getDropDownView(int i, View view, ViewGroup viewGroup) {
            TextViewSpinner textViewSpinner;
            if (view != null && (view instanceof TextViewSpinner)) {
                textViewSpinner = (TextViewSpinner) view;
            } else {
                ArcGISEditAttributesAdapter arcGISEditAttributesAdapter = ArcGISEditAttributesAdapter.this;
                textViewSpinner = new TextViewSpinner(arcGISEditAttributesAdapter.mContext);
            }
            textViewSpinner.setText(this.a.get(getItem(i)));
            return textViewSpinner;
        }
    }

    /* loaded from: classes.dex */
    protected class RangeSpinnerAdapter extends BaseAdapter {
        private String[] b;
        private int c;
        private int d;

        public RangeSpinnerAdapter(String[] strArr) {
            setValues(strArr);
        }

        public RangeSpinnerAdapter(double d, double d2) {
            int i = (int) d;
            this.c = i;
            int i2 = (int) d2;
            this.d = i2;
            if (i > i2) {
                this.d = i;
            }
        }

        @Deprecated
        public void setValues(String[] strArr) {
            if (strArr != null) {
                String[] strArr2 = new String[strArr.length];
                this.b = strArr2;
                System.arraycopy(strArr, 0, strArr2, 0, strArr.length);
                return;
            }
            this.b = new String[0];
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            TextViewSpinner textViewSpinner;
            if (view != null && (view instanceof TextViewSpinner)) {
                textViewSpinner = (TextViewSpinner) view;
            } else {
                ArcGISEditAttributesAdapter arcGISEditAttributesAdapter = ArcGISEditAttributesAdapter.this;
                textViewSpinner = new TextViewSpinner(arcGISEditAttributesAdapter.mContext);
            }
            textViewSpinner.setText(getItem(i));
            return textViewSpinner;
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            if (i >= getCount()) {
                return -1L;
            }
            return i;
        }

        @Override // android.widget.Adapter
        public String getItem(int i) {
            if (this.b != null) {
                if (i >= getCount()) {
                    return null;
                }
                return this.b[i];
            }
            return Integer.toString(this.c + i);
        }

        @Override // android.widget.Adapter
        public int getCount() {
            String[] strArr = this.b;
            if (strArr != null) {
                return strArr.length;
            }
            return (this.d - this.c) + 1;
        }
    }

    /* loaded from: classes.dex */
    protected class TextViewSpinner extends TextView implements ArcGISPopupStyle.IPopupStylable {
        public TextViewSpinner(Context context) {
            super(context);
            ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle();
            int convertDpInPixels = PopupUtil.convertDpInPixels(ArcGISEditAttributesAdapter.this.mContext, 10);
            setPadding(convertDpInPixels, 0, convertDpInPixels, 0);
            setHeight(ArcGISEditAttributesAdapter.this.a());
            setGravity(16);
            setLayoutParams(new AbsListView.LayoutParams(-1, ArcGISEditAttributesAdapter.this.a()));
            applyStyle(arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE);
            applyStyle(arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT.POPUP_BACKGROUND);
            arcGISPopupStyle.registerStylable(this);
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public Set<ArcGISPopupStyle.STYLE_ELEMENT> getRegisteredStyle() {
            return EnumSet.of(ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE, ArcGISPopupStyle.STYLE_ELEMENT.POPUP_BACKGROUND);
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public void applyStyle(ArcGISPopupStyle arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT style_element) {
            int i = AnonymousClass3.b[style_element.ordinal()];
            if (i != 1) {
                if (i != 2) {
                    return;
                }
                setBackgroundColor(arcGISPopupStyle.getPopupBackgroundColor());
                return;
            }
            setTextSize(1, arcGISPopupStyle.getFieldValueFontSize());
            setTypeface(arcGISPopupStyle.getFieldValueFontType(), arcGISPopupStyle.getFieldValueFontStyle());
            setTextColor(arcGISPopupStyle.getFieldValueColor());
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.esri.android.map.popup.ArcGISEditAttributesAdapter$3  reason: invalid class name */
    /* loaded from: classes.dex */
    public static /* synthetic */ class AnonymousClass3 {
        static final /* synthetic */ int[] a;
        static final /* synthetic */ int[] b;

        static {
            int[] iArr = new int[ArcGISPopupStyle.STYLE_ELEMENT.values().length];
            b = iArr;
            try {
                iArr[ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                b[ArcGISPopupStyle.STYLE_ELEMENT.POPUP_BACKGROUND.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                b[ArcGISPopupStyle.STYLE_ELEMENT.EDIT_FIELD.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            int[] iArr2 = new int[ArcGISAttributesAdapter.FIELD_TYPE.values().length];
            a = iArr2;
            try {
                iArr2[ArcGISAttributesAdapter.FIELD_TYPE.CODED_VALUE_DOMAIN.ordinal()] = 1;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[ArcGISAttributesAdapter.FIELD_TYPE.RANGE_DOMAIN.ordinal()] = 2;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[ArcGISAttributesAdapter.FIELD_TYPE.DATE.ordinal()] = 3;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a[ArcGISAttributesAdapter.FIELD_TYPE.TEXT.ordinal()] = 4;
            } catch (NoSuchFieldError unused7) {
            }
        }
    }

    /* loaded from: classes.dex */
    protected class SpinnerBackgroundDrawable extends EditTextBackgroundDrawable {
        protected SpinnerBackgroundDrawable() {
            super();
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.EditTextBackgroundDrawable, android.graphics.drawable.ShapeDrawable, android.graphics.drawable.Drawable
        public void draw(Canvas canvas) {
            ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle();
            Paint paint = new Paint();
            Rect bounds = getBounds();
            super.draw(canvas);
            Path path = new Path();
            paint.setStyle(Paint.Style.FILL);
            if (this.a) {
                paint.setColor(SupportMenu.CATEGORY_MASK);
            } else {
                paint.setColor(arcGISPopupStyle.getEditFieldColor());
            }
            int i = ((bounds.bottom - bounds.top) / 3) - 2;
            path.moveTo(bounds.right - 2, bounds.bottom - 2);
            path.lineTo(bounds.right - 2, bounds.bottom - i);
            path.lineTo(bounds.right - i, bounds.bottom - 2);
            path.close();
            canvas.drawPath(path, paint);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    /* loaded from: classes.dex */
    public class EditTextBackgroundDrawable extends ShapeDrawable {
        public static final int STROKE_WIDTH = 2;
        boolean a;

        public EditTextBackgroundDrawable() {
            super(new RectShape());
            this.a = false;
        }

        @Override // android.graphics.drawable.ShapeDrawable, android.graphics.drawable.Drawable
        public void draw(Canvas canvas) {
            ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle();
            Paint paint = new Paint();
            Rect bounds = getBounds();
            RectF rectF = new RectF(bounds.left, bounds.top, bounds.right, bounds.bottom);
            paint.setAntiAlias(true);
            paint.setColor(arcGISPopupStyle.getPopupBackgroundColor());
            paint.setStyle(Paint.Style.FILL);
            canvas.drawRect(rectF, paint);
            paint.setStrokeWidth(2.0f);
            paint.setAntiAlias(true);
            if (this.a) {
                paint.setColor(SupportMenu.CATEGORY_MASK);
            } else {
                paint.setColor(arcGISPopupStyle.getEditFieldColor());
            }
            paint.setStyle(Paint.Style.STROKE);
            int i = (bounds.bottom - bounds.top) / 8;
            canvas.drawLine(bounds.left, bounds.bottom - i, bounds.left, bounds.bottom, paint);
            canvas.drawLine(bounds.left, bounds.bottom, bounds.right, bounds.bottom, paint);
            canvas.drawLine(bounds.right, bounds.bottom, bounds.right, bounds.bottom - i, paint);
            if (this.a) {
                Paint paint2 = new Paint();
                paint2.setColor(SupportMenu.CATEGORY_MASK);
                paint2.setAntiAlias(true);
                paint2.setStyle(Paint.Style.STROKE);
                paint2.setTextAlign(Paint.Align.LEFT);
                paint2.setTextSize(i * 2);
                paint2.setTypeface(Typeface.create(Typeface.SERIF, 1));
                canvas.drawText("!", bounds.right - 20, bounds.bottom - i, paint2);
            }
        }
    }

    /* loaded from: classes.dex */
    protected class DateButtonOnClickListener implements View.OnClickListener {
        public DateTimePickerDialog dateTimeDialog;
        protected ArcGISAttributesAdapter.AttributeInfo mAttributeInfo;
        protected long mDate;
        protected long mMax;
        protected long mMin;

        public DateButtonOnClickListener(ArcGISAttributesAdapter.AttributeInfo attributeInfo, long j, long j2) {
            this.mAttributeInfo = attributeInfo;
            this.mMin = j;
            this.mMax = j2;
        }

        @Deprecated
        public DateButtonOnClickListener(ArcGISAttributesAdapter.AttributeInfo attributeInfo, long j, long j2, long j3) {
            this.mAttributeInfo = attributeInfo;
            this.mDate = j;
            this.mMin = j2;
            this.mMax = j3;
        }

        @Override // android.view.View.OnClickListener
        public void onClick(final View view) {
            if (this.dateTimeDialog == null) {
                ArcGISEditAttributesAdapter arcGISEditAttributesAdapter = ArcGISEditAttributesAdapter.this;
                DateTimePickerDialog dateTimePickerDialog = new DateTimePickerDialog(arcGISEditAttributesAdapter.mContext, this.mAttributeInfo.fieldInfo.getLabel());
                this.dateTimeDialog = dateTimePickerDialog;
                dateTimePickerDialog.a(this.mMin);
                this.dateTimeDialog.b(this.mMax);
                this.dateTimeDialog.setOkOnClickListener(new View.OnClickListener() { // from class: com.esri.android.map.popup.ArcGISEditAttributesAdapter.DateButtonOnClickListener.1
                    @Override // android.view.View.OnClickListener
                    public void onClick(View view2) {
                        long time = DateButtonOnClickListener.this.dateTimeDialog.getTime();
                        long a = ArcGISEditAttributesAdapter.this.a(ArcGISEditAttributesAdapter.this.getAttributeValue(DateButtonOnClickListener.this.mAttributeInfo.fieldInfo.getFieldName()));
                        ArcGISEditAttributesAdapter.this.mAttributes.put(DateButtonOnClickListener.this.mAttributeInfo.fieldInfo.getFieldName(), Long.valueOf(time));
                        ((TextView) view).setText(ArcGISEditAttributesAdapter.this.mValueFormat.formatValue(ArcGISEditAttributesAdapter.this.mFeatureType, Long.valueOf(time), ArcGISEditAttributesAdapter.this.mPopup.a.getFieldInfo(DateButtonOnClickListener.this.mAttributeInfo.fieldInfo.getFieldName())));
                        if (ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null && time != a) {
                            ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupModified();
                        }
                        DateButtonOnClickListener.this.dateTimeDialog.dismiss();
                    }
                });
                this.dateTimeDialog.setCancelOnClickListener(new View.OnClickListener() { // from class: com.esri.android.map.popup.ArcGISEditAttributesAdapter.DateButtonOnClickListener.2
                    @Override // android.view.View.OnClickListener
                    public void onClick(View view2) {
                        DateButtonOnClickListener.this.dateTimeDialog.dismiss();
                    }
                });
            }
            this.dateTimeDialog.show();
            ArcGISEditAttributesAdapter arcGISEditAttributesAdapter2 = ArcGISEditAttributesAdapter.this;
            this.dateTimeDialog.setTime(arcGISEditAttributesAdapter2.a(arcGISEditAttributesAdapter2.getAttributeValue(this.mAttributeInfo.fieldInfo.getFieldName())));
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public long a(Object obj) {
        long currentTimeMillis = System.currentTimeMillis();
        if (obj instanceof Integer) {
            return ((Integer) obj).longValue();
        }
        return obj instanceof Long ? ((Long) obj).longValue() : currentTimeMillis;
    }

    /* loaded from: classes.dex */
    private class c extends Button implements Required, ArcGISPopupStyle.IPopupStylable {
        private boolean b;

        public c(Context context) {
            super(context);
            ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle();
            setGravity(3);
            setPadding(PopupUtil.convertDpInPixels(ArcGISEditAttributesAdapter.this.mContext, 10), 0, 0, 0);
            setGravity(16);
            setHint(Popup.getPopupString("ags_enter_a_date", "Enter a date", getContext()));
            applyStyle(arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE);
            applyStyle(arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT.POPUP_BACKGROUND);
            arcGISPopupStyle.registerStylable(this);
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public void setRequiredState(boolean z) {
            this.b = z;
            if (z) {
                synchronized (ArcGISEditAttributesAdapter.this.a) {
                    if (ArcGISEditAttributesAdapter.this.a.incrementAndGet() == 1 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                        ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(false);
                    }
                }
                return;
            }
            synchronized (ArcGISEditAttributesAdapter.this.a) {
                if (ArcGISEditAttributesAdapter.this.a.get() > 0 && ArcGISEditAttributesAdapter.this.a.decrementAndGet() == 0 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                    ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(true);
                }
            }
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public boolean getRequiredState() {
            return this.b;
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public Set<ArcGISPopupStyle.STYLE_ELEMENT> getRegisteredStyle() {
            return EnumSet.of(ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE, ArcGISPopupStyle.STYLE_ELEMENT.POPUP_BACKGROUND);
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public void applyStyle(ArcGISPopupStyle arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT style_element) {
            int i = AnonymousClass3.b[style_element.ordinal()];
            if (i != 1) {
                if (i != 2) {
                    return;
                }
                getBackground().setColorFilter(arcGISPopupStyle.getPopupBackgroundColor(), PorterDuff.Mode.SRC);
                return;
            }
            setTextSize(1, arcGISPopupStyle.getFieldValueFontSize());
            setTypeface(arcGISPopupStyle.getFieldValueFontType(), arcGISPopupStyle.getFieldValueFontStyle());
            setTextColor(arcGISPopupStyle.getFieldValueColor());
        }
    }

    /* loaded from: classes.dex */
    private class d extends LinearLayout {
        public DatePicker a;
        public TimePicker b;

        public d(Context context) {
            super(context);
            setOrientation(1);
            this.a = new DatePicker(getContext());
            this.b = new TimePicker(getContext());
            addView(this.a, -1, -2);
            addView(this.b, -1, -2);
        }
    }

    /* loaded from: classes.dex */
    public class DateTimePickerDialog extends Dialog implements DatePicker.OnDateChangedListener {
        private Button b;
        private Button c;
        private View.OnClickListener d;
        private View.OnClickListener e;
        private long f;
        private long g;
        private Calendar h;
        private View i;
        private DatePicker j;
        private TimePicker k;

        public DateTimePickerDialog(Context context, String str) {
            super(context);
            this.f = Long.MIN_VALUE;
            this.g = LongCompanionObject.MAX_VALUE;
            super.setTitle(str);
        }

        @Override // android.app.Dialog
        protected void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            ScrollView scrollView = new ScrollView(getContext());
            LinearLayout linearLayout = new LinearLayout(getContext());
            linearLayout.setOrientation(1);
            if (ArcGISEditAttributesAdapter.this.mDatePickerResourceId > 0) {
                View inflate = ((Activity) ArcGISEditAttributesAdapter.this.mContext).getLayoutInflater().inflate(ArcGISEditAttributesAdapter.this.mDatePickerResourceId, (ViewGroup) null);
                this.i = inflate;
                if (inflate instanceof ViewGroup) {
                    for (int i = 0; i < ((ViewGroup) this.i).getChildCount(); i++) {
                        View childAt = ((ViewGroup) this.i).getChildAt(i);
                        if (childAt instanceof DatePicker) {
                            this.j = (DatePicker) childAt;
                        } else if (childAt instanceof TimePicker) {
                            this.k = (TimePicker) childAt;
                        }
                    }
                }
            } else {
                d dVar = new d(getContext());
                this.i = dVar;
                this.j = dVar.a;
                this.k = ((d) this.i).b;
            }
            linearLayout.addView(this.i, -1, -2);
            LinearLayout linearLayout2 = new LinearLayout(getContext());
            linearLayout2.setOrientation(0);
            Button button = new Button(getContext());
            this.b = button;
            button.setText(17039370);
            this.b.setOnClickListener(this.d);
            Button button2 = new Button(getContext());
            this.c = button2;
            button2.setText(17039360);
            this.c.setOnClickListener(this.e);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
            layoutParams.weight = 1.0f;
            linearLayout2.addView(this.b, layoutParams);
            linearLayout2.addView(this.c, layoutParams);
            linearLayout.addView(linearLayout2, -1, -2);
            scrollView.addView(linearLayout);
            setContentView(scrollView);
        }

        public void setOkOnClickListener(View.OnClickListener onClickListener) {
            this.d = onClickListener;
        }

        public void setCancelOnClickListener(View.OnClickListener onClickListener) {
            this.e = onClickListener;
        }

        public long getTime() {
            if (this.h == null) {
                this.h = Calendar.getInstance();
            }
            this.h.set(11, this.k.getCurrentHour().intValue());
            this.h.set(12, this.k.getCurrentMinute().intValue());
            return this.h.getTimeInMillis();
        }

        public void setTime(long j) {
            if (this.h == null) {
                this.h = Calendar.getInstance();
            }
            this.h.setTimeInMillis(j);
            this.j.init(this.h.get(1), this.h.get(2), this.h.get(5), this);
            this.k.setCurrentHour(Integer.valueOf(this.h.get(11)));
            this.k.setCurrentMinute(Integer.valueOf(this.h.get(12)));
        }

        long a() {
            return this.f;
        }

        void a(long j) {
            this.f = j;
        }

        long b() {
            return this.g;
        }

        void b(long j) {
            this.g = j;
        }

        @Override // android.widget.DatePicker.OnDateChangedListener
        public void onDateChanged(DatePicker datePicker, int i, int i2, int i3) {
            if (this.h == null) {
                this.h = Calendar.getInstance();
            }
            this.h.set(i, i2, i3);
            long j = this.g;
            if (j < LongCompanionObject.MAX_VALUE && j < this.h.getTimeInMillis()) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTimeInMillis(this.g);
                Context context = getContext();
                Toast.makeText(context, Popup.getPopupString("ags_cannot_exceed_maximum_date", ArcGISEditAttributesAdapter.this.mContext) + ": " + ArcGISValueFormat.a.format(calendar.getTime()), 0).show();
                this.j.init(calendar.get(1), calendar.get(2), calendar.get(5), this);
                return;
            }
            long j2 = this.f;
            if (j2 <= Long.MIN_VALUE || j2 <= this.h.getTimeInMillis()) {
                return;
            }
            Calendar calendar2 = Calendar.getInstance();
            calendar2.setTimeInMillis(this.f);
            Context context2 = getContext();
            Toast.makeText(context2, Popup.getPopupString("ags_cannot_exceed_minimum_date", ArcGISEditAttributesAdapter.this.mContext) + ": " + ArcGISValueFormat.a.format(calendar2.getTime()), 0).show();
            this.j.init(calendar2.get(1), calendar2.get(2), calendar2.get(5), this);
        }
    }

    protected void setBehavior(EditText editText, String str, int i, int i2) {
        a(editText, str, i, i2, (Domain) null);
    }

    private void a(final EditText editText, final String str, int i, int i2, Domain domain) {
        editText.setSingleLine();
        if (i > 0) {
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(i)});
        }
        Linkify.addLinks(editText, 1);
        if (i2 == 10 || i2 == 20) {
            editText.setInputType(InputDeviceCompat.SOURCE_TOUCHSCREEN);
            editText.addTextChangedListener(new e(editText, str, i2));
            editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { // from class: com.esri.android.map.popup.ArcGISEditAttributesAdapter.2
                @Override // android.view.View.OnFocusChangeListener
                public void onFocusChange(View view, boolean z) {
                    if (z) {
                        return;
                    }
                    if (editText.getText().length() == 1 && editText.getText().charAt(0) == '-') {
                        editText.setText("");
                        ArcGISEditAttributesAdapter.this.mAttributes.put(str, null);
                    }
                    if (editText.getText() == null || editText.getText().toString().trim().length() <= 0) {
                        return;
                    }
                    ArcGISEditAttributesAdapter.this.setRequiredState(editText, false);
                }
            });
        } else if (i2 == 30 || i2 == 40) {
            e eVar = new e(editText, str, i2);
            if (domain != null && (domain instanceof RangeDomain)) {
                eVar.d = (RangeDomain) domain;
            }
            editText.addTextChangedListener(eVar);
            editText.setInputType(12290);
        } else {
            editText.addTextChangedListener(new f(editText, str, i2));
        }
    }

    /* loaded from: classes.dex */
    private abstract class a implements TextWatcher {
        int a;
        protected EditText b;
        private String d;
        private boolean e = true;

        public a(EditText editText, String str, int i) {
            this.a = i;
            this.d = str;
            this.b = editText;
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r3v4, types: [java.lang.Integer] */
        /* JADX WARN: Type inference failed for: r3v5, types: [java.lang.Double] */
        /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:14:0x001d -> B:17:0x001e). Please submit an issue!!! */
        protected void a(String str) {
            int i = this.a;
            try {
            } catch (NumberFormatException unused) {
                str = null;
            }
            if (i == 10 || i == 20) {
                str = Integer.valueOf(str);
            } else {
                if (i == 30 || i == 40) {
                    str = Double.valueOf(str);
                }
                ArcGISEditAttributesAdapter.this.mAttributes.put(this.d, str);
            }
            ArcGISEditAttributesAdapter.this.mAttributes.put(this.d, str);
        }

        @Override // android.text.TextWatcher
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (i3 == 0) {
                ArcGISEditAttributesAdapter.this.setRequiredState(this.b, true);
            }
        }

        @Override // android.text.TextWatcher
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null && !this.e) {
                ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupModified();
            } else {
                this.e = false;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public class e extends a {
        RangeDomain d;

        public e(EditText editText, String str, int i) {
            super(editText, str, i);
        }

        @Override // android.text.TextWatcher
        public void afterTextChanged(Editable editable) {
            if (this.a == 20 && editable.length() > 0) {
                try {
                    Integer valueOf = Integer.valueOf(editable.toString());
                    if (valueOf.intValue() - valueOf.shortValue() != 0) {
                        if (editable.toString().startsWith("-")) {
                            if (editable.length() > 1) {
                                this.b.setText(Short.toString(ShortCompanionObject.MIN_VALUE));
                            }
                        } else {
                            this.b.setText(Short.toString(ShortCompanionObject.MAX_VALUE));
                        }
                    }
                } catch (NumberFormatException unused) {
                    if (editable.toString().startsWith("-")) {
                        if (editable.length() > 1) {
                            this.b.setText(Short.toString(ShortCompanionObject.MIN_VALUE));
                        }
                    } else {
                        this.b.setText(Short.toString(ShortCompanionObject.MAX_VALUE));
                    }
                }
            } else if (this.a == 10 && editable.length() > 0) {
                try {
                    Integer.valueOf(editable.toString());
                } catch (NumberFormatException unused2) {
                    if (editable.toString().startsWith("-")) {
                        if (editable.length() > 1) {
                            this.b.setText(Short.toString(ShortCompanionObject.MIN_VALUE));
                        }
                    } else {
                        this.b.setText(Short.toString(ShortCompanionObject.MAX_VALUE));
                    }
                }
            } else if (this.a == 30 && editable.length() > 0 && this.d != null) {
                try {
                    double doubleValue = Double.valueOf(editable.toString()).doubleValue();
                    if (doubleValue < this.d.getMinValue()) {
                        this.b.setText(Double.toString(this.d.getMinValue()));
                    } else if (doubleValue > this.d.getMaxValue()) {
                        this.b.setText(Double.toString(this.d.getMaxValue()));
                    }
                } catch (NumberFormatException unused3) {
                    if (editable.toString().startsWith("-")) {
                        if (editable.length() > 1) {
                            this.b.setText(Double.toString(this.d.getMinValue()));
                        }
                    } else {
                        this.b.setText(Double.toString(this.d.getMaxValue()));
                    }
                }
            }
            if (editable.length() > 0) {
                ArcGISEditAttributesAdapter.this.setRequiredState(this.b, false);
            } else {
                ArcGISEditAttributesAdapter.this.setRequiredState(this.b, true);
            }
            super.a(editable.toString());
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public class f extends a {
        public f(EditText editText, String str, int i) {
            super(editText, str, i);
        }

        @Override // android.text.TextWatcher
        public void afterTextChanged(Editable editable) {
            super.a(editable.toString());
            if (editable.length() > 0) {
                ArcGISEditAttributesAdapter.this.setRequiredState(this.b, false);
            } else {
                ArcGISEditAttributesAdapter.this.setRequiredState(this.b, true);
            }
        }
    }

    /* loaded from: classes.dex */
    protected class DefaultAttributeValueEditText extends EditText implements Required, ArcGISPopupStyle.IPopupStylable {
        EditTextBackgroundDrawable a;

        public DefaultAttributeValueEditText(Context context) {
            super(context);
            ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) ArcGISEditAttributesAdapter.this.mPopup.getLayout().getStyle();
            EditTextBackgroundDrawable editTextBackgroundDrawable = new EditTextBackgroundDrawable();
            this.a = editTextBackgroundDrawable;
            setBackgroundDrawable(editTextBackgroundDrawable);
            int convertDpInPixels = PopupUtil.convertDpInPixels(ArcGISEditAttributesAdapter.this.mContext, 10);
            setPadding(convertDpInPixels, convertDpInPixels, convertDpInPixels, convertDpInPixels);
            applyStyle(arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE);
            arcGISPopupStyle.registerStylable(this);
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public void setRequiredState(boolean z) {
            this.a.a = z;
            if (z) {
                synchronized (ArcGISEditAttributesAdapter.this.a) {
                    if (ArcGISEditAttributesAdapter.this.a.incrementAndGet() == 1 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                        ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(false);
                    }
                }
                return;
            }
            synchronized (ArcGISEditAttributesAdapter.this.a) {
                if (ArcGISEditAttributesAdapter.this.a.get() > 0 && ArcGISEditAttributesAdapter.this.a.decrementAndGet() == 0 && ArcGISEditAttributesAdapter.this.mPopup.getPopupListener() != null) {
                    ArcGISEditAttributesAdapter.this.mPopup.getPopupListener().onPopupValidityChanged(true);
                }
            }
        }

        @Override // com.esri.android.map.popup.ArcGISEditAttributesAdapter.Required
        public boolean getRequiredState() {
            return this.a.a;
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public Set<ArcGISPopupStyle.STYLE_ELEMENT> getRegisteredStyle() {
            return EnumSet.of(ArcGISPopupStyle.STYLE_ELEMENT.FIELD_VALUE, ArcGISPopupStyle.STYLE_ELEMENT.EDIT_FIELD);
        }

        @Override // com.esri.android.map.popup.ArcGISPopupStyle.IPopupStylable
        public void applyStyle(ArcGISPopupStyle arcGISPopupStyle, ArcGISPopupStyle.STYLE_ELEMENT style_element) {
            int i = AnonymousClass3.b[style_element.ordinal()];
            if (i == 1) {
                setTextSize(1, arcGISPopupStyle.getFieldValueFontSize());
                setTypeface(arcGISPopupStyle.getFieldValueFontType(), arcGISPopupStyle.getFieldValueFontStyle());
                setTextColor(arcGISPopupStyle.getFieldValueColor());
            } else if (i != 3) {
            } else {
                EditTextBackgroundDrawable editTextBackgroundDrawable = new EditTextBackgroundDrawable();
                this.a = editTextBackgroundDrawable;
                setBackgroundDrawable(editTextBackgroundDrawable);
            }
        }
    }

    @Override // com.esri.android.map.popup.PopupValid
    public boolean isValid() {
        return this.a.get() == 0;
    }

    @Override // com.esri.android.map.popup.ArcGISAttributesAdapter
    public void refresh() {
        this.a.set(0);
    }
}
